package com.noisyair.android.alvin;

import android.content.Context;
import com.google.tts.TTS;

public class Talker {
	
	// The speech synthesizer:
	static TTS tts;
	// A boolean to check if the talker key is pressed. If it is pressed, then the user can
	// touch a View and its contents will be spoken
	static boolean talkButtonIsPressed = false;
	
	// a flag to ensure the Talker is not init'ed more than once
	private static boolean isReady = false;
	
	public static void init(Context c){
		
		if(!isReady){
			tts = new TTS(c, ttsInitListener, true);
			isReady = true;
		}
	}
	
	private static TTS.InitListener ttsInitListener = new TTS.InitListener() {
		public void onInit(int version) {
			//speak("Started up");
	    }
	};
	
	public static void speak(String s){
		tts.speak(s, 0, null);
	}
	
	// Basically setter and getter for the talk button variable
	public static void setShouldTalk(boolean b){
		talkButtonIsPressed = b;
	}
	
	public static boolean shouldTalk(){
		return talkButtonIsPressed;
	}
}
